#include "RedirectMessage.h"


RedirectMessage::RedirectMessage(string _path)
	:PipeMessage(PipeMessage::REDIRECT)
{
	mPath = _path;
	mBufferChanged = true;
}

RedirectMessage::RedirectMessage( BYTE* _buff )
	:PipeMessage(PipeMessage::REDIRECT)
{
	mBuffer = _buff;
	ParseBuffer();
}


RedirectMessage::~RedirectMessage(void)
{
}

UINT RedirectMessage::GetBufferSize()
{
	return MAX_PATH;
}

UINT RedirectMessage::CreateBuffer( UINT _startPos /*= 0*/ )
{
	char tmpPath[MAX_PATH + 1];
	strcpy_s(tmpPath, mPath.c_str());
	memcpy_s(mBuffer + _startPos, MAX_PATH, tmpPath, MAX_PATH);

	return _startPos + MAX_PATH;
}

void RedirectMessage::ParseBuffer()
{
	char tmpPath[MAX_PATH + 1];
	memcpy_s(tmpPath, MAX_PATH, mBuffer + sizeof(MessageType) , MAX_PATH);

	mPath = tmpPath;
}
